SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].gspOrder_SEARCH
(
@orderId int = null,
@customerId int = null,
@productId int = null,
@createdDate datetime = null,
@lastModifiedDate datetime = null,
@commitDate datetime = null,
@sendDate datetime = null,
@isDeleted bit = null,
@isCommited bit = null
)
AS

SELECT
  *
FROM
  [dbo].[Order]
WHERE
  (@orderId IS NULL OR [OrderId] = @orderId)
AND
  (@customerId IS NULL OR [CustomerId] = @customerId)
AND
  (@productId IS NULL OR [ProductId] = @productId)
AND
  (@createdDate IS NULL OR [CreatedDate] = @createdDate)
AND
  (@lastModifiedDate IS NULL OR [LastModifiedDate] = @lastModifiedDate)
AND
  (@commitDate IS NULL OR [CommitDate] = @commitDate)
AND
  (@sendDate IS NULL OR [SendDate] = @sendDate)
AND
  (@isDeleted IS NULL OR [IsDeleted] = @isDeleted)
AND
  (@isCommited IS NULL OR [IsCommited] = @isCommited)


GO
